<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="/weui/dist/style/weui.min.css"/>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <script src="/jquery/dist/jquery.min.js"></script>
  </head>
  <body>
    <h1><%= title %></h1>
    <p class="wifi-tips">请绑定流量卡号</p>
    <form>

    </form>
    <div class="weui_cells weui_cells_form">
      <div class="weui_cell">
        <div class="weui_cell_hd"><label class="weui_label">卡号</label></div>
        <div class="weui_cell_bd weui_cell_primary">
          <input class="weui_input card_number" type="number" pattern="[0-9]*" placeholder="请输入流量卡号"/>
        </div>
      </div>
      <div class="weui_cell">
        <div class="weui_cell_hd"><label class="weui_label">密码</label></div>
        <div class="weui_cell_bd weui_cell_primary">
          <input class="weui_input card_pwd" type="password" placeholder="请输入流量卡密码"/>
        </div>
      </div>
      <div class="weui_cell">
        <div class="weui_cell_hd"><label class="weui_label">手机号</label></div>
        <div class="weui_cell_bd weui_cell_primary">
          <input class="weui_input user_mobile" type="number" placeholder="请输入常用手机号"/>
        </div>
      </div>
    </div>
    <div class="weui_cells_tips">填写手机号码可在流量快用完是短信提醒您, 非必须</div>
    <div class="weui_btn_area">
      <a class="weui_btn weui_btn_primary" href="javascript:" id="submit_bind">确定</a>
    </div>
  </body>
  <script>
    $(function(){
      $('#submit_bind').on('click', function(){
        var
                card_number = $('.card_number').val(),
                card_pwd = $('.card_pwd').val(),
                user_mobile = $('.user_mobile').val(),
                postData = {
                  card : card_number,
                  pwd : card_pwd,
                  mobile : user_mobile
                };

        $.ajax({
          url : '/bind',
          type: 'POST',
          data: postData,
          dataType : 'json',
          success : function(res){
            window.location.href = '/wechat/bind/success';
          },
          error : function(res){
            alert('失败:' + res.responseJSON);
          }
        });
      });
    });
  </script>
</html>
